<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="../templates/principal.xhtml">

    <ui:define name="head">
        <style type="text/css">
            .ui-datatable tbody td.wrap {
                white-space: normal;
                word-wrap: break-word;
                text-align: left;
            } 
        </style>
    </ui:define>

    <ui:define name="content" id="content">
        <h:form id="frmLog">
            <p:panel id="panel" header="Bem Vindo ao Cadastro de Log do Sistema">
                <p:growl id="messages" life="5000" />

                <p:dataTable id="tabLog" widgetVar="wtabLog" var="log" value="#{logSistemaBean.lazyModel}" 
                             lazy="true" paginator="true" rows="12" paginatorPosition="top"
                             emptyMessage="Nenhum Registro Retornado ..." filterEvent="enter">

                    <p:column style="width:150px;" headerText="Acessos dos Usuários" filterBy="#{log.dscUsuario}">
                        <p:rowToggler />
                    </p:column>

                    <p:column headerText="Processos Executados pelos Usuários" filterBy="#{log.dscSistema}">
                        <h:outputText value="#{log.datUpdate}">
                            <f:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy" />
                        </h:outputText>
                    </p:column>

                    <p:rowExpansion>
                        <p:dataTable id="tabLogDetalhe" widgetVar="wtabLogDetalhe" var="logDetalhe" value="#{log.logSistemaDetalheList}" resizableColumns="true"
                                     paginator="true" rows="20" paginatorPosition="top" emptyMessage="Nenhum Registro Retornado ..." filterEvent="enter">
                            <p:column style="width: 550px;" headerText="Acessos dos Usuários" sortBy="#{logDetalhe.dscUsuario}">
                                <h:outputText value="#{logDetalhe.dscUsuario}" />
                            </p:column>
                            <p:column styleClass="wrap" headerText="Processos Executados pelos Usuários" sortBy="#{logDetalhe.dscSistema}">
                                <h:outputText value="#{logDetalhe.dscSistema}" />
                            </p:column>
                        </p:dataTable>
                    </p:rowExpansion>
                    
                    <f:facet name="footer">
                        <div style="text-align: right;">
                            <p:commandButton id="atualizaLog" action="#{loginBean.loginInicio}" value="Atualiza Dados"
                                             update=":frmLog:panel" icon="ui-icon-pencil" title="Atualizar Dados do Sistema" />
                        </div>
                    </f:facet>
                </p:dataTable>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>
